﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Threading;

namespace Hi_Baidu.Timer
{
    /// <summary>
    ///     提供了获取要申请好友信息的超时计算与相关操作
    /// </summary>
    class GetPostFriendInfoTimeOutEvent : TimeOutEvent
    {
        private String username;

        public GetPostFriendInfoTimeOutEvent(String username, String Key, int Interval, int TryCount) 
            : base(Key, Interval, TryCount)
        {
            this.username = username;
            this.OnTryFull += new EventHandler<EventArgs>(GetPostFriendInfoTimeOutEvent_OnTryFull);
            this.OnTick += new EventHandler<EventArgs>(GetPostFriendInfoTimeOutEvent_OnTick);
        }

        void GetPostFriendInfoTimeOutEvent_OnTick(object sender, EventArgs e)
        {
            //重试发送
            Hi_Baidu.ProcessModel.FriendProcessModel.GetPostFriendInfo(Encoding.Default.GetBytes(this.username), Hi_Baidu.Globle.user.DIC_USERINFO["USERNAME"]);
        }

        void GetPostFriendInfoTimeOutEvent_OnTryFull(object sender, EventArgs e)
        {
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new PUBLIC_DELEGATE(Globle.ShowWindow));
        }
    }
}
